package com.zengqingfa.exercise.jvm;

/**
 * @author zengqingfa
 * @className User
 * @description
 * @create 2021/10/19 18:22
 */
public class User {
    private int id;

    private String name;

    public User() {
    }

    public User(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void print() {
        System.out.println("类加载器加载");
    }

    @Override
    protected void finalize() throws Throwable {
        //拯救一次
        FinalizeTest.coll.add(this);
        System.out.println(this.getId() + "对象被回收");
    }
}